package com.woniu.airent.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.airent.dto.HouseDto;
import com.woniu.airent.service.HouseManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("manageHouse")
public class ManageHouseController {

    @Autowired
    HouseManageService houseManageService;

    @RequestMapping("/list")
    @ResponseBody
    public PageInfo<HouseDto> listCheckedHouse(int currentPage, int pageSize) {
        PageInfo<HouseDto> houseDtoPageInfo = houseManageService.listInfor(currentPage, pageSize);
        return houseDtoPageInfo;
    }

    @RequestMapping("/showInfor")
    public String showInfor(int id, HttpServletRequest request) {
        HouseDto house = houseManageService.showInfor(id);
        request.setAttribute("house",house);
        return "view/showInfor";
    }

}
